/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package questionbook.model;

import java.util.Date;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;

/**
 * Represents an given Comment for a defines Answer
 * @author stefanstift
 */
public class Comment extends StandardModel{

    /**
     * The content of the Comment
     */
    private String text;

    /**
     * The User who wrote the Comment
     */
    private Person commenter;

    /**
     * The Type of the Comment (e.g. think right, sure wrong,..)
     */
    private CommentType commentType;

    /**
     * The Create Date of the Comment 
     */
    private Date createdAt;

    /**
     * Creates a new Comment instance with the specified URI
     *
     * @param uri
     */
    public Comment(URI uri) {
        super(uri);
    }

    /**
     * Creates a new Comment instance with the specified URI-String
     *
     * @param uri
     */
    public Comment(String uri) {
        super(uri);
    }

    /**
     *
     * @return the content of the Comment as a Literal
     */
    public Literal getTextLiteral() {
        return this.getStringLiteral(text);
    }

    /**
     *
     * @return the content of the Comment
     */
    public String getText() {
        return text;
    }

    /**
     * Sets the Content of the Comment
     *
     * @param text
     */
    public void setText(String text) {
        this.text = text;
    }

    /**
     *
     * @return the User who worte the Comment
     */
    public Person getCommenter() {
        return commenter;
    }

    /**
     * Sets the User who wrote the Comment
     *
     * @param commenter
     */
    public void setCommenter(Person commenter) {
        this.commenter = commenter;
    }

    /**
     *
     * @return the Type of the Comment (e.g. think right, sure wrong,..)
     */
    public CommentType getCommentType() {
        return commentType;
    }

    /**
     * Sets the Type of the Comment (e.g. think right, sure wrong,..)
     *
     * @param commentType
     */
    public void setCommentType(CommentType commentType) {
        this.commentType = commentType;
    }

    /**
     *
     * @return Timestamp of Create-Date as Long-Literal
     */
    public Literal getCreatedAtLiteral() {
        return this.getLongLiteral(this.createdAt.getTime());
    }

    /**
     *
     * @return String-Representation of the Create-Date
     */
     public String getCreatedAtString() {
        return this.format.format(createdAt);
    }

    /**
     *
     * @return Date-Object of the Create-Date
     */
    public Date getCreatedAt() {
        return createdAt;
    }

    /**
     * Sets the Create-Date with a Timestamp-String
     *
     * @param timestamp
     */
    public void setCreatedAt(String timestamp) {
        this.createdAt = new Date(Long.parseLong(timestamp));
    }

    /**
     * Sets the Create-Date with a Date-Object
     *
     * @param createdAt
    */
    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

}
